/**   
 * @Title: BaseServiceImpl.java 
 * CopyRight(c)2010-DMX 
 */
package com.dmx.fw.service.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.criterion.DetachedCriteria;

import com.dmx.fw.bean.PageInfo;
import com.dmx.fw.dao.interfaces.Dao;
import com.dmx.fw.service.interfaces.Service;

/**
 * Base class for Business Services - use this class for utility methods and
 * generic CRUD methods.
 * @author: system
 * @date: 2006
 * @version V1.0 
 * 
 */
public class BaseServiceImpl implements Service {
    protected final Log log = LogFactory.getLog(getClass());
    protected Dao dao ;
    
    /**
     * @see com.dmx.fw.service.interfaces.Service#setDao(org.appfuse.dao.Dao)
     */
    public void setDao(Dao dao) {
        this.dao = dao;
    }
    public List getObjects(Class clazz,Serializable[] id){
    	return dao.getObjects(clazz, id);
    }
    public List getObjectsByCriteria(final DetachedCriteria detachedCriteria)throws Exception{
    	return dao.getObjectsByCriteria(detachedCriteria);
    }
    public List getObjectsByCriteria(final DetachedCriteria detachedCriteria,final PageInfo pageInfo)throws Exception{
    	return dao.getObjectsByCriteria(detachedCriteria,pageInfo);
    }
    /**
     * @see com.dmx.fw.service.interfaces.Service#getObject(java.lang.Class, java.io.Serializable)
     */
    public Object getObject(Class clazz, Serializable id) {
        return dao.getObject(clazz, id);
    }
    
    /**
     * @see com.dmx.fw.service.interfaces.Service#getObjects(java.lang.Class)
     */
    public List getObjects(Class clazz) {
        return dao.getObjects(clazz);
    }
    
    /**
     * @see com.dmx.fw.service.interfaces.Service#removeObject(java.lang.Class, java.io.Serializable)
     */
    public void removeObject(Class clazz, Serializable id) {
        dao.removeObject(clazz, id);
    }
    public void removeObject(Object o){
    	dao.removeObject(o);
    }
    /**
     * @see com.dmx.fw.service.interfaces.Service#saveObject(java.lang.Object)
     */
    public void saveObject(Object o) throws Exception{
        dao.saveObject(o);
    }
    public void updateObject(Object o){
    	dao.updateObject(o);
    }
    public void createObject(Object o) {
        dao.create(o);
    }
	@Override
	public void saveAll(Collection entities) throws Exception{
		// TODO Auto-generated method stub
		dao.saveAll(entities);
	}
}
